<?php
/**
 * Created by PhpStorm.
 * User: Duke
 * Date: 2019/11/4
 * Time: 14:37
 */
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Admin\Controller;
use App\Model\AdminMenuModel;
use Illuminate\Support\Facades\View;

class AlphaController extends Controller{

    public function __construct(){
        // 自动加载左侧导航栏
        $this->autoLeftMenu();
    }

    public function autoLeftMenu(){
        $category = AdminMenuModel::where('pid',0)->get()->toArray();
        foreach($category as $key => $value){
            $category[$key]['son'] = AdminMenuModel::where('pid',$value['id'])->get()->toArray();
        }
        View::share('category', $category);
    }
}
